package Top200;

/**
 * @author zhangmin
 * @create 2022-02-23 9:57
 */
public class maxSubArray53 {
    public int maxSubArray(int[] nums) {
        int n=nums.length;
        int pre=nums[0],res=pre;
        for (int i =1; i < n; i++) {
            int cur=Math.max(pre+nums[i],nums[i]);
            res=Math.max(cur,res);
            pre=cur;
        }
        return res;
    }
}
